import { BaseIO } from "./baseIO";

/**
 * 指示灯模块
 * @class Glt
 * @extends {Module}
 */
interface GltState {}
interface GltCapability {}
export type FlashRate = "OFF" | "SLOW" | "MEDIUM" | "QUICK" | "CONTINUOUS";
export class Glt extends BaseIO<GltState, GltCapability> {
  constructor(modName: string, mod: any) {
    super(modName, mod);
  }

  /**
   * 存款灯
   * @param {string} FlashRate 闪动频率
   * @return Promise
   */
  SetBillAcceptorLight(FlashRate: FlashRate) {
    Trace(EC_INFO, "-->Glt:SetBillAcceptorLight");
    return new Promise<number>((resolve, reject) => {
      this.mod.SetBillAcceptorLight(FlashRate, (ret: string) => {
        Trace(EC_INFO, "<--Glt:SetBillAcceptorLight ret=" + ret);
        resolve(parseInt(ret));
      });
    });
  }
  /**
   * 读卡灯
   * @param {string} FlashRate 闪动频率
   * @return Promise
   */
  SetCardReaderLight(FlashRate: FlashRate) {
    Trace(EC_INFO, "-->Glt:SetCardReaderLight");
    return new Promise<number>((resolve, reject) => {
      this.mod.SetCardReaderLight(FlashRate, (ret: string) => {
        Trace(EC_INFO, "<--Glt:SetCardReaderLight ret=" + ret);
        resolve(parseInt(ret));
      });
    });
  }
  /**
   * 灯
   * @param {string} FlashRate 闪动频率
   * @return Promise
   */
  SetChequeUnitLight(FlashRate: FlashRate) {
    Trace(EC_INFO, "-->Glt:SetChequeUnitLight");
    return new Promise<number>((resolve, reject) => {
      this.mod.SetChequeUnitLight(FlashRate, (ret: string) => {
        Trace(EC_INFO, "<--Glt:SetChequeUnitLight ret=" + ret);
        resolve(parseInt(ret));
      });
    });
  }
  /**
   * 硬币口灯
   * @param {string} FlashRate 闪动频率
   * @return Promise
   */
  SetCoinDispenserLight(FlashRate: FlashRate) {
    Trace(EC_INFO, "-->Glt:SetCoinDispenserLight");
    return new Promise<number>((resolve, reject) => {
      this.mod.SetCoinDispenserLight(FlashRate, (ret: string) => {
        Trace(EC_INFO, "<--Glt:SetCoinDispenserLight ret=" + ret);
        resolve(parseInt(ret));
      });
    });
  }
  /**
   * 出钞口灯
   * @param {string} FlashRate 闪动频率
   * @return Promise
   */
  SetNoteDispenserLight(FlashRate: FlashRate) {
    Trace(EC_INFO, "-->Glt:SetNoteDispenserLight");
    return new Promise<number>((resolve, reject) => {
      this.mod.SetNoteDispenserLight(FlashRate, (ret: string) => {
        Trace(EC_INFO, "<--Glt:SetNoteDispenserLight ret=" + ret);
        resolve(parseInt(ret));
      });
    });
  }
  /**
   * 信封存放处灯
   * @param {string} FlashRate 闪动频率
   * @return Promise
   */
  SetEnvelopeDepositoryLight(FlashRate: FlashRate) {
    Trace(EC_INFO, "-->Glt:SetEnvelopeDepositoryLight");
    return new Promise<number>((resolve, reject) => {
      this.mod.SetEnvelopeDepositoryLight(FlashRate, (ret: string) => {
        Trace(EC_INFO, "<--Glt:SetEnvelopeDepositoryLight ret=" + ret);
        resolve(parseInt(ret));
      });
    });
  }
  /**
   * 存折打印灯
   * @param {string} FlashRate 闪动频率
   * @return Promise
   */
  SetPassbookPrinterLight(FlashRate: FlashRate) {
    Trace(EC_INFO, "-->Glt:SetPassbookPrinterLight");
    return new Promise<number>((resolve, reject) => {
      this.mod.SetPassbookPrinterLight(FlashRate, (ret: string) => {
        Trace(EC_INFO, "<--Glt:SetPassbookPrinterLight ret=" + ret);
        resolve(parseInt(ret));
      });
    });
  }
  /**
   * 密码键盘灯
   * @param {string} FlashRate 闪动频率
   * @return Promise
   */
  SetPinPadLight(FlashRate: FlashRate) {
    Trace(EC_INFO, "-->Glt:SetPinPadLight");
    return new Promise<number>((resolve, reject) => {
      this.mod.SetPinPadLight(FlashRate, (ret: string) => {
        Trace(EC_INFO, "<--Glt:SetPinPadLight ret=" + ret);
        resolve(parseInt(ret));
      });
    });
  }
  /**
   * 凭条灯
   * @param {string} FlashRate 闪动频率
   * @return Promise
   */
  SetReceiptPrinterLight(FlashRate: FlashRate) {
    Trace(EC_INFO, "-->Glt:SetReceiptPrinterLight");
    return new Promise<number>((resolve, reject) => {
      this.mod.SetReceiptPrinterLight(FlashRate, (ret: string) => {
        Trace(EC_INFO, "<--Glt:SetReceiptPrinterLight ret=" + ret);
        resolve(parseInt(ret));
      });
    });
  }
  /**
   * 信封发放灯
   * @param {string} FlashRate 闪动频率
   * @return Promise
   */
  SetEnvelopeDispenserLight(FlashRate: FlashRate) {
    Trace(EC_INFO, "-->Glt:SetEnvelopeDispenserLight");
    return new Promise<number>((resolve, reject) => {
      this.mod.SetEnvelopeDispenserLight(FlashRate, (ret: string) => {
        Trace(EC_INFO, "<--Glt:SetEnvelopeDispenserLight ret=" + ret);
        resolve(parseInt(ret));
      });
    });
  }

  /**
   * 打开或关闭相关模块指示灯
   * @param {string} strLightName  "DOCUMENTPRINTER" "SCANNER" "FINGERPRINT" "BARCODE" "INVOICE" "UKEY" "CAMERA"
   * @param {string} strFlashRate  "OFF" "SLOW" "MEDIUM" "QUICK" "CONTINUOUS"
   * @return Promise
   */
  SetGuidLigtEx(strLightName: any, FlashRate: any) {
    Trace(EC_INFO, "-->Glt:SetGuidLigtEx");
    return new Promise<number>((resolve, reject) => {
      this.mod.SetGuidLigtEx(strLightName, FlashRate, (ret: string) => {
        Trace(EC_INFO, "<--Glt:SetGuidLigtEx ret=" + ret);
        resolve(parseInt(ret));
      });
    });
  }

  /**
   * 打开或关闭相关模块指示灯
   * @param {number} 指示灯序号
   * @param {string} strFlashRate  "OFF" "SLOW" "MEDIUM" "QUICK" "CONTINUOUS"
   * @returns {Promise<json>} - {mod:this.modName, ret: '', param: arg}
   * @return {String} return.mod 模块名
   * @return {String} return.ret 事件 <br> sgnSetGuidLight - 点灯完成 <br> Timeout - 超时 <br> FatalError - 失败 <br> DeviceError - 设备故障 <br>
   * @return {Array} return.param - 事件参数 无
   */
  SetGuidLight(nIdx: number, strMode: string) {
    Trace(EC_INFO, "-->Glt:SetGuidLight");
    return new Promise<number>((resolve, reject) => {
      this.mod.SetGuidLight(nIdx, strMode, (ret: string) => {
        Trace(EC_INFO, "<--Glt:SetGuidLight ret=" + ret);
        resolve(parseInt(ret));
      });
    });
  }

  SetScanner(FlashRate: FlashRate) {
    return this.SetGuidLight(12, FlashRate);
  }
  SetFingerPrint(FlashRate: FlashRate) {
    return this.SetGuidLight(16, FlashRate);
  }
  SetUkey(FlashRate: FlashRate) {
    return this.SetGuidLight(21, FlashRate);
  }

  /**
   * 获取扩展状态信息
   * @param {string} StatusItem 扩展状态信息字段名字
   * @return Promise 扩展状态信息
   */
  GetExtendedStatusSync(StatusItem: any) {
    return new Promise<number>((resolve, reject) => {
      Trace(EC_INFO, "-->Glt:GetExtendedStatusSync()");
      this.mod.GetExtendedStatusSync(StatusItem, (ret: string) => {
        Trace(EC_INFO, "<--Glt:GetExtendedStatusSync()");
        resolve(parseInt(ret));
      });
    });
  }
}

export default Glt;
